package com.efrei.schoolmanager.tools;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class DaoConf {

	static Properties props;

	private static void loadProperties() throws IOException {
		String projectDir = System.getProperty("user.dir");
		if (props == null) {
			props = new Properties();
			FileInputStream fis = new FileInputStream(projectDir
					+ File.separator + "conf" + File.separator
					+ "database.properties");
			props.load(fis);
			fis.close();
		}
	}

	public static String getTypeBase() throws IOException {
		loadProperties();
		return props.getProperty("connection.type");
	}

	public static String getHostName() throws IOException {
		loadProperties();
		return props.getProperty("connection.hostname");
	}

	public static String dataBaseName() throws IOException {
		loadProperties();
		return props.getProperty("connection.dataBaseName");

	}

	public static String getPassword() throws IOException {
		loadProperties();
		return props.getProperty("connection.password");
	}

	public static String getUserName() throws IOException {
		loadProperties();
		return props.getProperty("connection.user");
	}

}
